﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <script src="scripts/Soapi.js" type="text/javascript"></script>


    <script type="text/javascript">

        function run() {
            var apiKey = 'qgAq_KfDu0KYzlNG-qaTuw';
            
            var factory = new Soapi.RouteFactory('api.stackoverflow.com', apiKey);


            // get the third page of 10 of users with 'z' in displayname

            var route = factory.Users().applyParameters({
                filter: 'z',
                pagesize: 10,
                page: 3
            });

            route.getResponse(
                function success(data) {
                    var usernames = [];
                    for (var i = 0; i < data.items.length; i++) {
                        usernames.push(data.items[i].display_name);
                    };
                    document.getElementById("output").innerHTML = '<p><strong>Results</strong></p><p>page:' + data.page
                + '</p><p>pagesize:' + data.pagesize
                + '</p><p>total:' + data.total
                + '</p><p>nusernames:<br/>' + usernames.join('<br/>');
                },
                function error(err) {
                    alert("Error: " + err.code + " " + err.message);
                },
                2000);
        }
    </script>

</head>
<body onload="run()">
    <pre id="output">
</pre>
</body>
</html>
